package com.hymjweb.demo.hymj.login_manage.service;

import com.hymjweb.demo.framework.sys.BaseService;
import com.hymjweb.demo.framework.util.util.Md5SaltUtil;
import com.hymjweb.demo.hymj.system_maintenance.user.bean.XtUserPojo;
import com.hymjweb.demo.hymj.system_maintenance.user.service.XtUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @BelongsProject: demo1
 * @BelongsPackage: com.hymjweb.demo.hymj.system_login.service
 * @Author: luoge
 * @CreateTime: 2019-10-15 21:25
 * @Description: 登录业务类
 */
@Component
public class LoginService extends BaseService {

    @Autowired
    private XtUserService xtUserService;

    public XtUserPojo getSystemUserPojoByMobileAndPassWord(String mobile, String passWord) {

        XtUserPojo xtUserPojo = xtUserService.findUK(mobile);

        if (xtUserPojo == null) {
            return null;
        }

        String pwdInDb = xtUserPojo.getPassword();

        if (pwdInDb == null) {
            return null;
        }

        boolean verifyValue = Md5SaltUtil.getSaltVerifyMd5AndSha(passWord, pwdInDb);

        if (verifyValue) {
            return xtUserPojo;
        }

        return null;
    }
}
